<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'预计整改时间'"></u-navbar>
		<view>
			<u-form :model="feedbackForm" ref="feedbackForm" label-width="100px" style="padding: 24rpx;">
				<u-form-item label-position="left" label="整改时间" prop="feedbackTimeString" >
					<u-input type="text" :border="border" placeholder="请选择预计整改完成时间" v-model="feedbackForm.feedbackTimeString"
					:disabled="true" @click="show =true"/>
				</u-form-item>
				<u-form-item label-position="left" label="反馈描述" prop="feedbackRemark">
					<u-input type="text" :border="border" placeholder="如设备需重新购买,邮寄需要三天"
						v-model="feedbackForm.feedbackRemark" />
				</u-form-item>
			</u-form>
			<u-picker v-model="show" mode="time" :params="params" @confirm="confirmEnd"></u-picker>
		</view>
		<u-button @click="submit" type="primary" style="margin: 24rpx;">确认</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				mode: 'range',
				border: true,
				feedbackForm: {},
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true
				},
				feedbackForm: {
					feedbackTimeString: '',
					feedbackRemark: '',
				},
				rules: {
					feedbackTimeString: [{
						required: true,
						message: '请选择时间',
						trigger: ['change', 'blur'],
					}],
					feedbackRemark: [{
						required: true,
						message: '请输入反馈描述',
						trigger: ['change', 'blur'],
					}]
				}
			}
		},
		methods: {
			onLoad(e) {
				this.feedbackForm.ucId = e.ucId
			},
			onShow() {

			},
			back() {
				window.native.back()
			},
			submit() {
				this.$refs.feedbackForm.validate(valid => {
					if (valid) {
						this.utils.request("/api/app/inHiddenDanger/reportRectificationTime", this.feedbackForm, "post", "app",
							true).then(res => {
							uni.navigateTo({
								url: '/pages/index/firedanger/index'
							})
						}).catch(error => {
							console.log(error)
						})
					} else {
						console.log('验证失败');
					}
				});
			},
			confirmEnd(e) {
				console.log(e)
				this.feedbackForm.feedbackTimeString = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute +
					':' + e.second;
			}
		},
		onReady() {
			this.$refs.feedbackForm.setRules(this.rules);
		},
	}
</script>

<style lang="scss" scoped>
	.title {
		color: $u-type-primary;
		text-align: center;
		padding: 20rpx 0 0 0;
	}
</style>
